package logic

import (
	"context"
	"usershop/user_srv/model/redis"

	"usershop/user_srv/internal/svc"
	"usershop/user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type SendSmsLimitLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewSendSmsLimitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsLimitLogic {
	return &SendSmsLimitLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *SendSmsLimitLogic) SendSmsLimit(in *user.SendSmsLimitRequest) (*user.SendSmsLimitResMsg, error) {
	// todo: 短信限流

	//短信限流
	res := redis.SendSmsLimit(in.Mobile)

	return &user.SendSmsLimitResMsg{
		Islimit: res,
	}, nil
}
